Previous code would access the array element before checking that
the index was within bounds, and therefore cause a TypeError.
It wasn't noticed earlier because at least one visible children
is in each panel box in all session modes.
https://bugzilla.gnome.org/show_bug.cgi?id=619955
return null;
// Start at the back and work backward
- let index = children.length - 1;
- while (!children[index].visible && index >= 0)
- index--;
-
+ let index;
+ for (index = children.length - 1; index >= 0; index--) {
+ if (children[index].visible)
+ break;
+ }
if (index < 0)
return null;
return null;
// Start at the front and work forward
- let index = 0;
- while (!children[index].visible && index < children.length)
- index++;
-
+ let index;
+ for (index = 0; index < children.length; index++) {
+ if (children[index].visible)
+ break;
+ }
if (index == children.length)
return null;